<?php
class Online_model extends CI_Model
{
    private $ci,$redis;
    public function __construct(){
        $this->load->database();
        $this->ci = & get_instance();
        //链接redis
        $this->ci->load->driver('cache');
        $this->ci->cache->redis->is_supported();
        $this->redis = $this->ci->cache->redis;
    }

    public function addOnline($data){
    	$rs = $this->db->insert("online",$data);
        if($rs){
            return $this->db->insert_id();
        }else{
            return false;
        }
    }   

    public function getOnline($data,$limit='all',$orderby=''){
        $this->db->select()->from("online")->where($data);
        if($limit!='all'){
             $limit = abs($limit);
             $this->db->limit($limit);
        }
        if($orderby!=''){
            $this->db->order_by($orderby);
        }
        $query =  $this->db->get();
        if($limit==1) return $query->row_array();
        return $query->result_array();
    }

    public function updateOnline($data,$where){
        $rs = $this->db->update("online",$data,$where);
        if($rs){
            return true;
        }else{
            return false;
        }
    }

    public function delOnline($data){
        return $this->db->delete("online",$data);
    }   



   
}